<?php


namespace App\Controller;

use App\Model\HyUser;
use Hyperf\HttpServer\Annotation\AutoController;
use Vtiful\Kernel\Excel;

/**
 * @AutoController()
 * Class ExportController
 * @package App\Controller
 */
class ExportController extends AbstractController
{
    public function test1()
    {
        $time = time();
        $config = [
            'path' => BASE_PATH . '/runtime/excels' // xlsx文件保存路径
        ];

        $excel = new Excel($config);

        $fileObject = $excel->constMemory('tutorial02.xlsx','Sheet1',false);
        
        $excel = $fileObject->fileName('test1.xlsx', 'sheet1')
            ->header(['333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌']);
        
        for ($i = 0 ;$i <200000 ; $i ++){
            $excel = $excel->data(
                [
                    ['333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌','333', '猪无敌']
                ]
            );
        }
        $filePath = $excel->output();
        var_dump("耗时：".(time()-$time));
        var_dump(123);
        var_dump($filePath);
    }
}